package heathot.servlet;

import heathot.bookservice.BookService;
import heathot.bookservice.BookServiceimpl;
import heathot.dao.impl.BookDao;
import heathot.dao.impl.BookDaoimpl;
import heathot.entiy.Book;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BookshowServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
		response.setContentType("text/html,charset=utf-8");
		PrintWriter out = response.getWriter();
		BookService service = new BookServiceimpl();
		List<Book> books = service.selectBooks();
		//response.sendRedirect("");
		request.setAttribute("books",books);
		//response.sendRedirect("");
		request.getRequestDispatcher("/showbook.jsp").forward(request,response);
		out.flush();
		out.close();
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
				doGet(request, response);
	}

}
